package com.xh.baselibrary.callback;



import androidx.lifecycle.MediatorLiveData;

import com.xh.baselibrary.model.RequestErrBean;

import retrofit2.Response;

/**
 * @author xh on 2019/8/19
 */
    public class CallBack<T extends Object> extends RetrofitCallback<T> {

    BaseViewModel d;
    MediatorLiveData<T> mediatorLiveData;


    public CallBack(BaseViewModel d, MediatorLiveData<T> mediatorLiveData){

        this.d=d;
        this.mediatorLiveData=mediatorLiveData;
    }

    @Override
    protected void onError(String type,String messgae) {
        d.getErrorLiveData().setValue(new RequestErrBean(type,messgae));

    }



    @Override
    protected  void onSuccess(Response<T> response){
        mediatorLiveData.setValue(response.body());


    };

}
